﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace benefit.Controllers
{
    public class ErrorController : BenefitHelper.Tools.BaseControl
    {
        //
        // GET: /Error/

        public ActionResult Index(string uid, string pdate)
        {

            int operatorId = Convert.ToInt32(uid);
            BenefitHelper.Sys.Operator op = new BenefitHelper.Sys.Operator().GetModel(operatorId, db);
            ViewBag.op = op;

            ViewBag.uid = uid;
            Common.Web.Cookie cookie = new Common.Web.Cookie();
            if (!string.IsNullOrEmpty(cookie.GetCookie("querydate")))
            {
                if (pdate.Length == 6)
                { //查询月数据上面出错
                    ViewBag.pdate = cookie.GetCookie("querydate");
                }
                else if (pdate.Length == 4)
                { //查询年数据上面出错
                    ViewBag.pdate = cookie.GetCookie("querydate");
                }
                else//一般日数据查询出错
                {
                    BenefitHelper.Sys.TradeHistory th = new BenefitHelper.Sys.TradeHistory();
                    th = th.GetSettlementModel(pdate, db);//查询数据库
                    int tid = th.Id;
                    ViewBag.pdate = pdate;

                }
            }
            else
            {
                Response.Redirect("/Home");
            }
            ViewBag.Hpdate = new BenefitHelper.Sys.TradeHistory().AddHorizontalLineIntoPdate(ViewBag.pdate);

            return View();

        }

        public ActionResult HasNoPrower(int uid, string pdate)
        {
            int operatorId = Convert.ToInt32(uid);
            BenefitHelper.Sys.Operator op = new BenefitHelper.Sys.Operator().GetModel(operatorId, db);
            ViewBag.op = op;

            ViewBag.uid = uid;
            Common.Web.Cookie cookie = new Common.Web.Cookie();
            if (!string.IsNullOrEmpty(cookie.GetCookie("querydate")))
            {
                if (pdate.Length == 6)
                { //查询月数据上面出错
                    ViewBag.pdate = cookie.GetCookie("querydate");
                }
                else if (pdate.Length == 4)
                { //查询年数据上面出错
                    ViewBag.pdate = cookie.GetCookie("querydate");
                }
                else//一般日数据查询出错
                {
                    BenefitHelper.Sys.TradeHistory th = new BenefitHelper.Sys.TradeHistory();
                    th = th.GetSettlementModel(pdate, db);//查询数据库
                    int tid = th.Id;
                    ViewBag.pdate = pdate;

                }
            }
            else
            {
                Response.Redirect("/Home");
            }
            ViewBag.Hpdate = new BenefitHelper.Sys.TradeHistory().AddHorizontalLineIntoPdate(ViewBag.pdate);

            return View();
        }

    }
}
